<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看订单')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-order-edit" th:object="${shopOrder}">
            <h4 class="form-header h4">订单操作</h4>
            <div class="row">
                <div class="col-sm-offset-3 col-sm-12">
                    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()" th:if="${shopOrder.status eq 0}" ><i class="fa fa-check"></i>保 存</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-warning" onclick="changeAmount()" th:if="${shopOrder.status eq 0}"><i class="fa fa-edit"></i>修改金额 </button>
<!--                    <button type="button" class="btn btn-sm btn-success" onclick="closeItem()" th:if="${shopOrder.status eq 1}"><i class="fa fa-plus"></i>完 成</button>-->
                    <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"  th:if="${shopOrder.status eq 3}" ><i class="fa search" ></i>退 款</button>
                    <button type="button" class="btn btn-sm btn-info" onclick="changeAmount()" th:if="${shopOrder.status eq 10}"><i class="fa fa-refresh"  ></i> 查询退款进度 </button>
<!--                    <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-remove"></i>删 除</button>-->
                </div>
            </div>
            <input name="id" th:field="*{id}" type="hidden">
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">编号：</label>
                        <div class="col-sm-8">
                            <input name="sn" th:field="*{sn}" class="form-control" type="text" required readonly="true">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"> 订单状态 </label>
                        <div class="col-sm-8">
                                [[${strStatus}]]
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">来源：</label>
                        <div class="col-sm-8">
                                微信小程序
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">支付方式类型：</label>
                        <div class="col-sm-8" style="align-items: center; justify-content: center;">
                            微信支付
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">收货人：</label>
                        <div class="col-sm-8">
                            <input name="consignee" th:value="${consignee}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">电话：</label>
                        <div class="col-sm-8">
                            <input name="phone" th:field="*{phone}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">订单金额：</label>
                        <div class="col-sm-8">
                            <input name="amount" th:field="*{amount}" class="form-control" type="text" required  readonly="true">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">已付金额：</label>
                        <div class="col-sm-8">
                            <input name="amountPaid" th:field="*{amountPaid}" class="form-control" type="text" required readonly="true">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">创建日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                <input name="createDate" th:value="${#dates.format(shopOrder.createDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">修改日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                <input name="modifyDate" th:value="${#dates.format(shopOrder.modifyDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-2 control-label">地址：</label>
                <div class="col-xs-10">
                    <input name="address" th:field="*{address}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-2 control-label">备注：</label>
                <div class="col-xs-10">
                    <textarea name="memo" maxlength="500" class="form-control" rows="3">[[*{memo}]]</textarea>
                </div>
            </div>

            <h4 class="form-header h4">商品信息</h4>

            <div class="form-group">
                <label class="col-sm-3 control-label">商品名称：</label>
                <div class="col-sm-8">
                    <input name="goods_name" th:value="${orderItem.name}" class="form-control" type="text" required readonly="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品价格：</label>
                <div class="col-sm-8">
                    <input name="goods_price" th:field="*{price}" class="form-control" type="text" required readonly="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品数量：</label>
                <div class="col-sm-8">
                    <input name="quantity" th:field="*{quantity}" class="form-control" type="text" required readonly="true">
                </div>
            </div>
            <h4 class="form-header h4">商家信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">店铺名称：</label>
                <div class="col-sm-8">
                    <input name="businessShopId" th:field="*{businessShop.name}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "normal/order";
        $("#form-order-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-order-edit').serialize());
            }
        }

        function changeAmount(){
            var orderId =  $("input[name='id']").val();
            var url = prefix + "/changeAmount/" + orderId;
            $.modal.openFull("修改金额",url,"380");
        }

        $("input[name='createDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>